﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using StockCommon;
using StockImport.TaskLog;

namespace CalendarInputApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String[] lines = textBox1.Lines;
            Regex dateRegx = new Regex(@"(\d+)/(\d+)/(\d+)", RegexOptions.IgnoreCase);

            foreach (String s in lines)
            {
                String s1 = s.Trim();
                Match m = dateRegx.Match(s1);
                if (m.Success)
                {
                    String seg=m.Groups[0].ToString();
                    String s2 = s1.Substring(seg.Length);
                    s2 = s2.Trim();
                    DateTime d=DateTime.Parse(seg);
                    
                    System.Diagnostics.Debug.WriteLine(d.ToShortDateString() + "\t" + s2);
                    CalenderHelper.addNoTrade(d,s2);
                    UpdateScheduleNaviServices.logItem(d, "休市", s2, 10);
                }
            }
            DateTime dd = DateTime.Parse("2012/01/01");
            DateTime dc = DateTime.Parse("2003/12/31");
            while (true)
            {
                if (dd.CompareTo(dc) < 0)
                    break;
                CalenderHelper.addNoTrade(dd, "元旦");
                UpdateScheduleNaviServices.logItem(dd, "休市", "元旦", 10);
                dd=dd.AddYears(-1);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if(String.IsNullOrWhiteSpace(dateEdit1.Text))
                return;
                if(String.IsNullOrWhiteSpace(textBox2.Text))
                    return;
                DateTime dt = dateEdit1.DateTime;
                UpdateScheduleNaviServices.logItem(dt, "休市", textBox2.Text, -1);
                


        }
    }
}
